package com.example.mainstream.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.shopapp.R;
import com.example.shopapp.bean.OrderBean;

/**
 * 文件名：OrderAdapter
 * 作  者： admin
 * 描述：TOOD
 */
public class OrderAdapter extends BaseQuickAdapter<OrderBean, BaseViewHolder> {

    private OnOrderListener listener;
    private Context context;
    public OrderAdapter(Context context,OnOrderListener listener) {
        super(R.layout.item_order);
        this.listener = listener;
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderBean item) {
        helper.setText(R.id.spc_tv_shop_name_msg,item.getTitle());
        helper.setText(R.id.spc_tv_pinlei,"已购买"+item.getCount()+"件");
        helper.setText(R.id.spc_tv_zong_price,item.getPrice()+"元");
        Glide.with(context).load(item.getUrl()).into((ImageView) helper.getView(R.id.spc_iv_page));

        helper.getView(R.id.rl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener!= null){
                    listener.onOrderClick(item.getId(),item.getAddress_id());
                }
            }
        });
    }
}
